﻿using Newtonsoft.Json;
using PioneerBoilerplate.Repository.Base;
using PioneerBoilerplate.Service.Admin.Api;
using PioneerBoilerplate.Util;
using PioneerBoilerplate.Util.Helpers;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

namespace PioneerBoilerplate.Api.Db
{
    public class DataSeedProvider: Data
    {
        public DataSeedProvider()
        {

        }
        private readonly IApiService _apiService;

        public DataSeedProvider(IApiService apiService)
        {
            _apiService = apiService;
            var filePath = Path.Combine(AppContext.BaseDirectory, "Db/Data/data.json").ToPath();
            var jsonData = FileHelper.ReadFile(filePath);
            var data = JsonConvert.DeserializeObject<Data>(jsonData);

            this.ApiTree = data.ApiTree;
            this.ViewTree = data.ViewTree;
            this.PermissionTree = data.PermissionTree;

            this.DictionaryTypes = data.DictionaryTypes;
            this.Dictionaries = data.Dictionaries;
            this.Apis = data.Apis;
            this.Users = data.Users;
            this.Roles = data.Roles;
            this.UserRoles = data.UserRoles;
            this.RolePermissions = data.RolePermissions;
            this.PermissionApis = data.PermissionApis;
        }

        public void GenerateRawdata() 
        {
            DataSeedProvider provider = new DataSeedProvider();
        }
    }
}
